//
// Created by jinyf on 2021/7/9.
//

#ifndef BILIRTMP_VIDEOCHANNEL_H
#define BILIRTMP_VIDEOCHANNEL_H

#include <inttypes.h>
#include <x264.h>
#include "JavaCallHelper.h"
#include "librtmp/rtmp.h"

class VideoChannel {
    typedef void (*VideoCallback)(RTMPPacket *packet);

public:
    VideoChannel();

    ~VideoChannel();

    void setVideoEncInfo(int width, int height, int fps, int bitrate);

    void encodeData(int8_t *data);


    void sendSpsPps(uint8_t sps[100], uint8_t pps[100], int len, int len1);

    void sendFrame(int type, int payload, uint8_t *p_payload);

    void setVideoCallback(VideoCallback callback);

private:
    int mWidth=0;
    int mHeight=0;
    int mFps=0;
    int mBitrate=0;


    int ySize=0;
    int uvSize=0;

    x264_t *videoCodec=0;

    //类似bytebuffer
    x264_picture_t *pic_in=0;


    VideoCallback callback;

public:
    JavaCallHelper *javaCallHelper;


};


#endif //BILIRTMP_VIDEOCHANNEL_H
